// pages/book/book.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    swiperList: [],
    activeIndex: 0,
    queryText: null,
  },
  getInput: function (e) {
    console.log(e.detail.value)
    this.setData({
      queryText: e.detail.value
    })
    this.carlist(e.detail.value)
  },
  setTabIndex(e) {
    console.log(e)
    let activeIndex = e.currentTarget.dataset.i;
    console.log(activeIndex);
    this.setData({
      activeIndex
    })
    // if(activeIndex==0){
    // 	this.distancelist();
    // }
    if (activeIndex == 1) {
      this.restlist();
    }
    if (activeIndex == 2) {
      this.pricelist();
    }
  },
  onLoad: function (options) {

    this.carlist('');

  },
  // onLoad :function(options) {
  //  this.carlist();
  //  this.pricelist();
  //  this.distancelist();
  //  this.restlist();
  // },
  // swiperList: [],
  carlist(name) {
    var that = this;
    console.log('====', this.queryText)
    wx.request({
      url: 'http://localhost:8080/blog/park/getparkmessage?parkname=' + name,
      success: (result) => {
        that.setData({
          swiperList: result.data.data.list
        })
        console.log(result);
        // console.log(queryText);
      }
    });
  },

  pricelist() {
    var that = this;
    wx.request({
      url: 'http://localhost:8080/blog/park/getcarprice',
      success: (result) => {
        that.setData({
          //swiperList:[],
          swiperList: result.data.data.list
        })
        console.log(result);
      }
    });
  },
  // distancelist(){
  //   var that=this;
  //   wx.request({
  //     url: 'http://localhost:8080/blog/park//getcardistance',
  //     success: (result) => {
  //       that.setData({
  //         //swiperList:[],
  //         swiperList: result.data.data.list
  //       })
  //       console.log(result);
  //     }
  //   });
  // },
  restlist() {
    var that = this;
    wx.request({
      url: 'http://localhost:8080/blog/park/getcarrest',
      success: (result) => {
        that.setData({
          //swiperList:[],
          swiperList: result.data.data.list
        })
        console.log(result);
      }
    });
  },


})